package itheima.com.mythreadpool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class MyThreadPoolDemo1 {
    public static void main(String[] args) throws InterruptedException {
        //创建默认线程池对象
        ExecutorService executorService = Executors.newCachedThreadPool();
        //ExecutorService---进行线程控制
        //Executors-----帮我们创建线程池对象
        //提交线程状态
        executorService.submit(()->{
            System.out.println(Thread.currentThread().getName()+"执行咯");
        });
        //线程控制睡眠时间
        Thread.sleep(1000);
        executorService.submit(()->{
            System.out.println(Thread.currentThread().getName()+"正在执行");
        });
        //将线程停止运行
        executorService.shutdown();
    }
}
